package iris.core
{
	import flash.display.DisplayObject;
	import flash.events.Event;
	import flash.events.KeyboardEvent;

	import mx.core.Application;

	public class ApplicationHelper
	{
		private static var _instance:ApplicationHelper;

		private var _application:mx.core.Application;

		public function ApplicationHelper(lock:SingletonLocker)
		{
			_application = Application.application as Application;
		}

		public function callLater(method:Function, parameter:Array = null, delay:Number = 1):void
		{
			if(delay > 1)
				_application.callLater(callLater, [method, parameter, delay - 1]);
			else
				_application.callLater(method, parameter);
		}

//		public function disableInteractiveUnderModal(activate:Boolean)
//		{
//			if(activate)
//			{
//				_application.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true, int.MAX_VALUE);
//			}
//		}
//
//		private function keyDownHandler(event:KeyboardEvent):void
//		{
//			trace(event.target)
//			if(_application.systemManager.numModalWindows > 0
//				&& _application.contains(event.target as DisplayObject))
//				event.stopImmediatePropagation();
//		}

		public static function get instance():ApplicationHelper
		{
			if(_instance == null)
				_instance = new ApplicationHelper(new SingletonLocker());
			return _instance;
		}
	}

}

class SingletonLocker
{

}